<?php

namespace app\store\validate;

use think\Validate;

class ComboValidate extends Validate
{
    protected $rule = [
        'user_grade_id' => 'require|integer|unique:combo',
        'combo_name' => 'require|max:100',
        'combo_image' => 'require',
        'origin_price' => 'float',
        'sell_price' => 'require|float',
        'combo_desc' => 'require',
        'give_integral' => 'requireWith|integer',
        'give_coupon' => 'requireWith',
        'give_balance' => 'requireWith|float',
        'status' => 'require|in:0,1'
    ];


    protected $message = [
        'id.require' => '非法请求',
        'combo_name.require' => '请输入套餐名称',
        'combo_image.require' => '请上传套餐封面',
        'user_grade_id.require' => '请选择会员等级',
        'user_grade_id.unique' => '相应的等级套餐已存在!',
        'sell_price.require' => '请输入销售条件',
        'combo_desc.require' => '请输入套餐描述',
        'give_integral.requireWith' => '请输入积分',
        'give_coupon.requireWith' => '请选择优惠券',
        'give_balance.requireWith' => '请输入余额',
        'status.require' => '非法请求',
    ];

    public function sceneEdit()
    {
        return $this->only(['id','user_grade_id','combo_amount','combo_desc','give_integral','give_coupon','give_balance','status'])
                    ->append('id','require|integer')
                    ->remove('user_grade_id','unique');
    }
}